/*
 * Copyright (c) 2014 - 2016. Company.Domain Co.Ltd. All rights reserved.
 */

package cn.com.dhc.danlu.activity.category;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import cn.com.dhc.danlu.R;
import cn.com.dhc.danlu.R.drawable;
import cn.com.dhc.danlu.activity.BaseActivity;
import cn.com.dhc.danlu.util.ACache;
import cn.com.dhc.danlu.util.CommonConst;
import cn.com.dhc.danlu.util.CommonUtils;
import cn.com.dhc.danlu.util.ToastUtil;

/**
 * author: MuWei
 * author: 刘立琦(<a href="mailto:liuliqi@danlu.com">liuliqi@danlu.com</a>)<br/>
 * version: 1.0.0<br/>
 * since: 2016-12-19 15:04<br/>
 *
 * <p>
 * 价格筛选画面
 * </p>
 */
public class CategoryPriceFilterActivity extends BaseActivity {
    /**
     * 最大值常量
     */
    private static final String MAX_NUM = "1000";
    /**
     * 低价格最大值常量
     */
    private static final String MAX_NUM_LOW = "500";
    /**
     * 中等价格最大值常量
     */
    private static final String MAX_NUM_MID = "2100";
    /**
     * 大家电最大值常量
     */
    private static final String MAX_NUM_HIGH = "5000";
    /**
     * 取消按钮
     */
    private LinearLayout llytCancel;
    /**
     * 价格区间 0-99
     */
    private RelativeLayout rlytPriceBetween1;
    private TextView txtPriceBetween1;
    private ImageView imgPriceBetween1;
    /**
     * 价格区间 50-99
     */
    private RelativeLayout rlytPriceBetween2;
    private TextView txtPriceBetween2;
    private ImageView imgPriceBetween2;
    /**
     * 价格区间 100-199
     */
    private RelativeLayout rlytPriceBetween3;
    private TextView txtPriceBetween3;
    private ImageView imgPriceBetween3;
    /**
     * 价格区间200-299
     */
    private RelativeLayout rlytPriceBetween4;
    private TextView txtPriceBetween4;
    private ImageView imgPriceBetween4;
    /**
     * 价格区间 300-499
     */
    private RelativeLayout rlytPriceBetween5;
    private TextView txtPriceBetween5;
    private ImageView imgPriceBetween5;
    /**
     * 价格区间500-999
     */
    private RelativeLayout rlytPriceBetween6;
    private TextView txtPriceBetween6;
    private ImageView imgPriceBetween6;
    /**
     * 价格区间 1000以上
     */
    private RelativeLayout rlytPriceBetween7;
    private TextView txtPriceBetween7;
    private ImageView imgPriceBetween7;
    /**
     * 全部价格
     */
    private RelativeLayout rlytAllPrice;
    private TextView txtAllPrice;
    private ImageView imgAllPrice;
    /**
     * 价格区间低价输入框
     */
    private EditText edtLowPrice;
    /**
     * 价格区间低价输入框
     */
    private EditText edtHighPrice;
    /**
     * 确定按钮
     */
    private TextView llytOk;
    /**
     * 意图对象
     */
    private Intent data = new Intent();
    private boolean allPrice = false;

    /**
     * 输入右的图片
     */
    private ImageView imgEdit;
    private String comeFrom;

    private OnClickListener clickListener = new OnClickListener() {

        @Override
        public void onClick(View view) {
            String priceTemp[];
            switch (view.getId()) {
                // 如果选择按钮1，也就是价格区间0-49
                case R.id.rlytPriceBetween1:
                    // 将得到的字符串拆分
                    // 0-99
                    priceTemp = getString(R.string.category_price_between_label_1).split("-");
                    if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("lowPrice")) {
                        // 0-49
                        priceTemp = getString(R.string.category_price_between_label_1low).split("-");
                    } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("midPrice")) {
                        // 0-89
                        priceTemp = getString(R.string.category_price_between_label_1mid).split("-");
                        //大家电
                    } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("highPrice")) {
                        // 0-499
                        priceTemp = getString(R.string.category_price_between_label_1h).split("-");
                    }
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    // 设置高价显示
                    edtHighPrice.setText(priceTemp[1]);
                    break;

                // 如果选择按钮2，也就是价格区间50-99
                case R.id.rlytPriceBetween2:
                    // 将得到的字符串拆分
                    // 100-199
                    priceTemp = getString(R.string.category_price_between_label_2).split("-");
                    if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("lowPrice")) {
                        // 50-99
                        priceTemp = getString(R.string.category_price_between_label_2low).split("-");
                    } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("midPrice")) {
                        // 90-199
                        priceTemp = getString(R.string.category_price_between_label_2mid).split("-");
                        //大家电
                    } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("highPrice")) {
                        // 500-999
                        priceTemp = getString(R.string.category_price_between_label_2h).split("-");
                    }
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    // 设置高价显示
                    edtHighPrice.setText(priceTemp[1]);
                    break;

                // 如果选择按钮3，也就是价格区间100-199
                case R.id.rlytPriceBetween3:
                    // 将得到的字符串拆分
                    // 200-299
                    priceTemp = getString(R.string.category_price_between_label_3).split("-");
                    if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("lowPrice")) {
                        // 100-199
                        priceTemp = getString(R.string.category_price_between_label_3low).split("-");
                    } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("midPrice")) {
                        // 200-399
                        priceTemp = getString(R.string.category_price_between_label_3mid).split("-");
                        //大家电
                    } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("highPrice")) {
                        // 1000-1999
                        priceTemp = getString(R.string.category_price_between_label_3h).split("-");
                    }
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    // 设置高价显示
                    edtHighPrice.setText(priceTemp[1]);
                    break;

                // 如果选择按钮4，也就是价格区间200-299
                case R.id.rlytPriceBetween4:
                    // 将得到的字符串拆分
                    // 300-399
                    priceTemp = getString(R.string.category_price_between_label_4).split("-");
                    if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("lowPrice")) {
                        // 200-399
                        priceTemp = getString(R.string.category_price_between_label_4low).split("-");
                    } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("midPrice")) {
                        // 400-699
                        priceTemp = getString(R.string.category_price_between_label_4mid).split("-");
                        //大家电
                    } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("highPrice")) {
                        //2000-4999
                        priceTemp = getString(R.string.category_price_between_label_4h).split("-");
                    }
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    edtHighPrice.setText(priceTemp[1]);
                    break;

                // 如果选择按钮5，也就是价格区间300-499
                case R.id.rlytPriceBetween5:
                    // 将得到的字符串拆分
                    // 400-499
                    priceTemp = getString(R.string.category_price_between_label_5).split("-");
                    if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("lowPrice")) {
                        // 400-499
                        priceTemp = getString(R.string.category_price_between_label_5low).split("-");
                    } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("midPrice")) {
                        // 700-1499
                        priceTemp = getString(R.string.category_price_between_label_5mid).split("-");
                        // 5000以上
                    } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("highPrice")) {
                        // 设置低价显示
                        edtLowPrice.setText(MAX_NUM_HIGH);
                        // 设置高价显示
                        edtHighPrice.setText("");
                        return;
                    }
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    edtHighPrice.setText(priceTemp[1]);
                    break;

                // 如果选择按钮6，也就是价格区间500-999
                case R.id.rlytPriceBetween6:
                    if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("lowPrice")) {
                        // 设置低价显示
                        edtLowPrice.setText(MAX_NUM_LOW);    //500以上
                        // 设置高价显示
                        edtHighPrice.setText("");
                        selectRadio(view.getId(), "");     //调用勾选方法
                        return;
                    }
                    // 将得到的字符串拆分
                    priceTemp = getString(R.string.category_price_between_label_6).split("-");
                    if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("midPrice")) {
                        // 1500-2099
                        priceTemp = getString(R.string.category_price_between_label_6mid).split("-");
                    }
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    // 设置高价显示
                    edtHighPrice.setText(priceTemp[1]);

                    break;

                // 如果选择按钮6，也就是价格区间1000以上
                case R.id.rlytPriceBetween7:
                    // 设置低价显示
                    edtLowPrice.setText(MAX_NUM);
                    if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("midPrice")) {
                        edtLowPrice.setText(MAX_NUM_MID);
                    }
                    // 设置高价显示
                    edtHighPrice.setText("");
                    break;

                case R.id.rlytAllPrice:
                    edtLowPrice.setText("");
                    edtHighPrice.setText("");
                    allPrice = true;
                    break;

                default:
                    break;
            }
            selectRadio(view.getId(), "");
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        getDelegate().setContentView(R.layout.layout_category_price_filter, R.layout_category_price_filter.class);
        setContentView(R.layout.layout_category_price_filter);

        initViews();
        setViews();
        setListener();
    }

    private void initViews() {
        llytCancel = (LinearLayout) findViewById(R.id.llytCancel);

        rlytPriceBetween1 = (RelativeLayout) findViewById(R.id.rlytPriceBetween1);
        rlytPriceBetween2 = (RelativeLayout) findViewById(R.id.rlytPriceBetween2);
        rlytPriceBetween3 = (RelativeLayout) findViewById(R.id.rlytPriceBetween3);
        rlytPriceBetween4 = (RelativeLayout) findViewById(R.id.rlytPriceBetween4);
        rlytPriceBetween5 = (RelativeLayout) findViewById(R.id.rlytPriceBetween5);
        rlytPriceBetween6 = (RelativeLayout) findViewById(R.id.rlytPriceBetween6);
        rlytPriceBetween7 = (RelativeLayout) findViewById(R.id.rlytPriceBetween7);
        rlytAllPrice = (RelativeLayout) findViewById(R.id.rlytAllPrice);

        txtPriceBetween1 = (TextView) findViewById(R.id.txtPriceBetween1);
        txtPriceBetween2 = (TextView) findViewById(R.id.txtPriceBetween2);
        txtPriceBetween3 = (TextView) findViewById(R.id.txtPriceBetween3);
        txtPriceBetween4 = (TextView) findViewById(R.id.txtPriceBetween4);
        txtPriceBetween5 = (TextView) findViewById(R.id.txtPriceBetween5);
        txtPriceBetween6 = (TextView) findViewById(R.id.txtPriceBetween6);
        txtPriceBetween7 = (TextView) findViewById(R.id.txtPriceBetween7);
        txtAllPrice = (TextView) findViewById(R.id.txtAllPrice);
        llytOk = (TextView) findViewById(R.id.llytOK);

        imgPriceBetween1 = (ImageView) findViewById(R.id.imgPriceBetween1);
        imgPriceBetween2 = (ImageView) findViewById(R.id.imgPriceBetween2);
        imgPriceBetween3 = (ImageView) findViewById(R.id.imgPriceBetween3);
        imgPriceBetween4 = (ImageView) findViewById(R.id.imgPriceBetween4);
        imgPriceBetween5 = (ImageView) findViewById(R.id.imgPriceBetween5);
        imgPriceBetween6 = (ImageView) findViewById(R.id.imgPriceBetween6);
        imgPriceBetween7 = (ImageView) findViewById(R.id.imgPriceBetween7);
        imgAllPrice = (ImageView) findViewById(R.id.imgAllPrice);
        imgEdit = (ImageView) findViewById(R.id.imgEdit);

        edtLowPrice = (EditText) findViewById(R.id.edtLowPrice);
        edtHighPrice = (EditText) findViewById(R.id.edtHighPrice);
    }

    @Override
    protected String getActivityTitle() {
        return null;
    }

    /**
     * 根据传入价格区间不同，显示隐藏不同价格列表
     */
    @SuppressLint("RtlHardcoded")
    private void setViews() {
        // 获取对话框当前的参值
        WindowManager.LayoutParams p = getWindow().getAttributes();
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        // 高度设置为屏幕的屏幕高度- 底部导航栏hight
        p.height = (int) (dm.heightPixels - dm.density * 53);
        // 宽度设置为屏幕的0.8
        p.width = (int) (dm.widthPixels * 0.8);
        // 设置生效
        getWindow().setAttributes(p);
        getWindow().setGravity(Gravity.RIGHT | Gravity.TOP);
        getLastClickPrice();
        Intent intent = getIntent();
        comeFrom = intent.getStringExtra("priseInterval");   // 价格区间
        if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("lowPrice")) {
            txtPriceBetween1.setText(getString(R.string.category_price_between_label_1low));
            txtPriceBetween2.setText(getString(R.string.category_price_between_label_2low));
            txtPriceBetween3.setText(getString(R.string.category_price_between_label_3low));
            txtPriceBetween4.setText(getString(R.string.category_price_between_label_4low));
            txtPriceBetween5.setText(getString(R.string.category_price_between_label_5low));
            txtPriceBetween6.setText(getString(R.string.category_price_between_label_6low));
            rlytPriceBetween7.setVisibility(View.GONE);
        } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("midPrice")) {   // 中等价格区间0--2100以上
            txtPriceBetween1.setText(getString(R.string.category_price_between_label_1mid));
            txtPriceBetween2.setText(getString(R.string.category_price_between_label_2mid));
            txtPriceBetween3.setText(getString(R.string.category_price_between_label_3mid));
            txtPriceBetween4.setText(getString(R.string.category_price_between_label_4mid));
            txtPriceBetween5.setText(getString(R.string.category_price_between_label_5mid));
            txtPriceBetween6.setText(getString(R.string.category_price_between_label_6mid));
            txtPriceBetween7.setText(getString(R.string.category_price_between_label_7mid));
        } else if (!TextUtils.isEmpty(comeFrom) && comeFrom.equals("highPrice")) {  // 大额价格区间0--5000以上
            txtPriceBetween1.setText(getString(R.string.category_price_between_label_1h));
            txtPriceBetween2.setText(getString(R.string.category_price_between_label_2h));
            txtPriceBetween3.setText(getString(R.string.category_price_between_label_3h));
            txtPriceBetween4.setText(getString(R.string.category_price_between_label_4h));
            txtPriceBetween5.setText(getString(R.string.category_price_between_label_5h));
            rlytPriceBetween6.setVisibility(View.GONE);
            rlytPriceBetween7.setVisibility(View.GONE);
        }
    }

    /***
     * 获取上次点击的价格
     */
    private void getLastClickPrice() {
        ACache aCache = ACache.get(getApplicationContext());
        String price = aCache.getAsString(CommonConst.ACacheComstants.PRICE); // 读取缓存价格
        if (price != null) {
            selectRadio(0, price);

            String[] priceTemp = null;
            // 不等于"全部"价格
            if (!price.equals(getResources().getText(R.string.category_all_label))) {
                if (price.equals(getString(R.string.category_price_between_label_1))) {
                    priceTemp = getString(R.string.category_price_between_label_1).split("-");
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    // 设置高价显示
                    edtHighPrice.setText(priceTemp[1]);
                } else if (price.equals(getString(R.string.category_price_between_label_2))) {
                    // 将得到的字符串拆分
                    priceTemp = getString(R.string.category_price_between_label_2).split("-");
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    // 设置高价显示
                    edtHighPrice.setText(priceTemp[1]);
                } else if (price.equals(getString(R.string.category_price_between_label_3))) {
                    // 将得到的字符串拆分
                    priceTemp = getString(R.string.category_price_between_label_3).split("-");
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    // 设置高价显示
                    edtHighPrice.setText(priceTemp[1]);
                } else if (price.equals(getString(R.string.category_price_between_label_4))) {
                    priceTemp = getString(R.string.category_price_between_label_4).split("-");
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    // 设置高价显示
                    edtHighPrice.setText(priceTemp[1]);
                } else if (price.equals(getString(R.string.category_price_between_label_5))) {
                    // 将得到的字符串拆分
                    priceTemp = getString(R.string.category_price_between_label_5).split("-");
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    // 设置高价显示
                    edtHighPrice.setText(priceTemp[1]);
                } else if (price.equals(getString(R.string.category_price_between_label_6))) {
                    // 将得到的字符串拆分
                    priceTemp = getString(R.string.category_price_between_label_6).split("-");
                    // 设置低价显示
                    edtLowPrice.setText(priceTemp[0]);
                    // 设置高价显示
                    edtHighPrice.setText(priceTemp[1]);
                } else if (price.equals(getString(R.string.category_price_between_label_7))) {
                    // 设置低价显示
                    edtLowPrice.setText(MAX_NUM);
                    // 设置高价显示
                    edtHighPrice.setText("");
                } else {
                    if (CommonUtils.isContainChinese(price)) {
                        // price 以上的金额
                        // 设置低价
                        edtLowPrice.setText(CommonUtils.filterNumber(price));
                        // 设置高价显示
                        edtHighPrice.setText("");
                    } else {
                        // 将得到的字符串拆分
                        priceTemp = price.split("-");
                        // 设置低价
                        edtLowPrice.setText(priceTemp[0]);
                        // 设置高价显示
                        edtHighPrice.setText(priceTemp[1]);
                    }
                    selectRadio(edtHighPrice.getId(), "");
                }
                selectRadio(edtHighPrice.getId(), "");  //选中编辑框栏
            } else {
                allPrice = true;
                selectRadio(rlytAllPrice.getId(), "");
            }
        } else {
            allPrice = true;
            selectRadio(rlytAllPrice.getId(), "");
        }
    }

    /**
     * 设置监听
     */
    private void setListener() {
        // 设置价格区间监听
        edtLowPrice.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View view, MotionEvent ev) {
                if (ev.getAction() == MotionEvent.ACTION_DOWN) {
                    selectRadio(view.getId(), "");
                }
                return false;
            }
        });
        edtHighPrice.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View view, MotionEvent ev) {
                if (ev.getAction() == MotionEvent.ACTION_DOWN) {
                    selectRadio(view.getId(), "");
                }
                return false;
            }
        });

        // 设置点击监听
        rlytAllPrice.setOnClickListener(clickListener);
        rlytPriceBetween1.setOnClickListener(clickListener);
        rlytPriceBetween2.setOnClickListener(clickListener);
        rlytPriceBetween3.setOnClickListener(clickListener);
        rlytPriceBetween4.setOnClickListener(clickListener);
        rlytPriceBetween5.setOnClickListener(clickListener);
        rlytPriceBetween6.setOnClickListener(clickListener);
        rlytPriceBetween7.setOnClickListener(clickListener);
        // 返回按钮点击事件监听，点击直接返回
        llytCancel.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                CommonUtils.hideSoftInputForce(CategoryPriceFilterActivity.this); // 强制隐藏键盘
                finish();
            }
        });
        llytOk.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                // 沿用以前的传值
                data.putExtra("price_type", "8");
                // 如果编辑框有值
                if (edtLowPrice.getText().toString().length() >= 1 || edtHighPrice.getText().toString().length() >= 1) {
                    // 如果左编辑框没值
                    if (edtLowPrice.getText().toString().length() == 0) {
                        // 设置低价为0
                        data.putExtra(CommonConst.IntentKey.LOW_PRICE, "0");
                        // 高价为右编辑框中的值
                        data.putExtra(CommonConst.IntentKey.HIGH_PRICE, edtHighPrice.getText().toString());
                        // 如果右编辑框没值
                    } else if (edtHighPrice.getText().toString().length() == 0) {
                        // 设置低价为0
                        data.putExtra(CommonConst.IntentKey.LOW_PRICE, edtLowPrice.getText().toString());
                        // 设置低价为左编辑框中的值
                        data.putExtra(CommonConst.IntentKey.HIGH_PRICE, "null");
                    } else if (Double.parseDouble(edtLowPrice.getText().toString()) > Double.parseDouble(edtHighPrice.getText().toString())) {  // 左 > 右
                        ToastUtil.getInstance().show(R.string.category_price_low_high_error_prompt); // 提示起始价格需要大于终止价格
                        return;
                    } else if (Double.parseDouble(edtLowPrice.getText().toString()) < Double.parseDouble(edtHighPrice.getText().toString())) { // 左 < 右
                        data.putExtra(CommonConst.IntentKey.LOW_PRICE, edtLowPrice.getText().toString());
                        data.putExtra(CommonConst.IntentKey.HIGH_PRICE, edtHighPrice.getText().toString());
                    } else if (Double.parseDouble(edtLowPrice.getText().toString()) == Double.parseDouble(edtHighPrice.getText().toString())) { // 左 == 右
                        data.putExtra(CommonConst.IntentKey.LOW_PRICE, edtLowPrice.getText().toString());
                        data.putExtra(CommonConst.IntentKey.HIGH_PRICE, edtHighPrice.getText().toString());
                    }
                } else if (allPrice) { // 全部
                    data.putExtra("allPrice", getResources().getText(R.string.category_all_label));
                    ACache.get(getApplicationContext()).remove(CommonConst.ACacheComstants.PRICE);
                } else {
                    // 什么都没选，也没编辑，低价为空，高价也为空
                    data.putExtra(CommonConst.IntentKey.LOW_PRICE, "null");
                    data.putExtra(CommonConst.IntentKey.HIGH_PRICE, "null");
                    ToastUtil.getInstance().show(R.string.category_price_filter_no_select);
                    return;
                }
                setResult(RESULT_OK, data);
                CommonUtils.hideSoftInputForce(CategoryPriceFilterActivity.this); // 隐藏键盘
                CategoryPriceFilterActivity.this.finish(); // 结束本活动
            }
        });
    }

    /**
     * 点击改变字体颜色和你勾选标志
     *
     * @param viewId
     *         所选View的ID
     * @param price
     *         价格区间
     */
    private void selectRadio(int viewId, String price) {
        CommonUtils.hideSoftInputForce(CategoryPriceFilterActivity.this); // 隐藏键盘
        if (R.id.rlytPriceBetween1 == viewId || txtPriceBetween1.getText().equals(price)) {
            txtPriceBetween1.setTextColor(Color.RED);
            imgPriceBetween1.setImageResource(drawable.ic_radio_button_cecked);
        } else {
            txtPriceBetween1.setTextColor(Color.BLACK);
            imgPriceBetween1.setImageResource(drawable.icon_price_uncheck);
        }
        if (R.id.rlytPriceBetween2 == viewId || txtPriceBetween2.getText().equals(price)) {
            txtPriceBetween2.setTextColor(Color.RED);
            imgPriceBetween2.setImageResource(drawable.ic_radio_button_cecked);
        } else {
            txtPriceBetween2.setTextColor(Color.BLACK);
            imgPriceBetween2.setImageResource(drawable.icon_price_uncheck);
        }

        if (R.id.rlytPriceBetween3 == viewId || txtPriceBetween3.getText().equals(price)) {
            txtPriceBetween3.setTextColor(Color.RED);
            imgPriceBetween3.setImageResource(drawable.ic_radio_button_cecked);
        } else {
            txtPriceBetween3.setTextColor(Color.BLACK);
            imgPriceBetween3.setImageResource(drawable.icon_price_uncheck);
        }

        if (R.id.rlytPriceBetween4 == viewId || txtPriceBetween4.getText().equals(price)) {
            txtPriceBetween4.setTextColor(Color.RED);
            imgPriceBetween4.setImageResource(drawable.ic_radio_button_cecked);
        } else {
            txtPriceBetween4.setTextColor(Color.BLACK);
            imgPriceBetween4.setImageResource(drawable.icon_price_uncheck);
        }

        if (R.id.rlytPriceBetween5 == viewId || txtPriceBetween5.getText().equals(price)) {
            txtPriceBetween5.setTextColor(Color.RED);
            imgPriceBetween5.setImageResource(drawable.ic_radio_button_cecked);
        } else {
            txtPriceBetween5.setTextColor(Color.BLACK);
            imgPriceBetween5.setImageResource(drawable.icon_price_uncheck);
        }
        if (R.id.rlytPriceBetween6 == viewId || txtPriceBetween6.getText().equals(price)) {
            txtPriceBetween6.setTextColor(Color.RED);
            imgPriceBetween6.setImageResource(drawable.ic_radio_button_cecked);
        } else {
            txtPriceBetween6.setTextColor(Color.BLACK);
            imgPriceBetween6.setImageResource(drawable.icon_price_uncheck);
        }
        if (R.id.rlytPriceBetween7 == viewId || txtPriceBetween7.getText().equals(price)) {
            txtPriceBetween7.setTextColor(Color.RED);
            imgPriceBetween7.setImageResource(drawable.ic_radio_button_cecked);
        } else {
            txtPriceBetween7.setTextColor(Color.BLACK);
            imgPriceBetween7.setImageResource(drawable.icon_price_uncheck);
        }
        if (R.id.rlytAllPrice == viewId || txtAllPrice.getText().equals(price)) { // 全部栏
            txtAllPrice.setTextColor(Color.RED);
            imgAllPrice.setImageResource(drawable.ic_radio_button_cecked);
        } else {
            txtAllPrice.setTextColor(Color.BLACK);
            imgAllPrice.setImageResource(drawable.icon_price_uncheck);
        }
        if (R.id.edtLowPrice == viewId || R.id.edtHighPrice == viewId) { // 输入价格栏
            imgEdit.setImageResource(drawable.ic_radio_button_cecked);
        } else {
            imgEdit.setImageResource(drawable.icon_price_uncheck);
        }
    }
}